<?php

class Tools extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('Dict_model', 'dict');
    }

    public function index() {
        $this->load->view('tools.html');

    }

    public function getResult($content = '') {


        $content = $this->input->post('content');
        
        $data = $this->dict->translate($content);

        if (isset($data['basic']['explains'])) {
            foreach ($data['basic']['explains'] as $key => $value) {
                echo $value;
            }
        } elseif (isset($data['translation'])) {
            echo $data['translation'][0];
        } else {
            echo '没找到';
        }

    }
} 